export const genTemplateArr = (len: number, { start = 1, suffix = '@2x' }: { start?: number, suffix?: string } = {}) =>
    new Array(len).fill(1).map((_, idx) => `${idx + start}${suffix}`)
export const genTemplateArrFill0 = (len: number, { suffix = '', pre = '', start = 0 }: { start?: number, pre?: string, suffix?: string } = {}) => new Array(len).fill(1).map((_, idx) => {
    idx += start
    const width = len.toString().length
    const num = idx.toString().padStart(width < 2 ? 2 : width, '0')
    return `${pre}${num}${suffix}`
})

export const isMobile = () => {
    const ua = navigator.userAgent.toLowerCase()
    const mobileAgents = ['iphone', 'ipod', 'ipad', 'android', 'webos', 'blackberry', 'iemobile', 'opera mini']
    for (let i = 0; i < mobileAgents.length; i++) {
        if (ua.indexOf(mobileAgents[i]) !== -1) return true
    }
    return false
}